<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
    <!-- Loading Bootstrap -->
    <link href="/static/admin/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
    <!-- Loading Flat UI -->
    <link href="/static/admin/Flat/dist/css/flat-ui.css" rel="stylesheet">
    <link href="/static/admin/Flat/docs/assets/css/demo.css" rel="stylesheet">
    <link rel="shortcut icon" href="/static/admin/Flat/img/favicon.ico">
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
    <!--[if lt IE 9]>
    <script src="dist/js/vendor/html5shiv.js"></script>
    <script src="dist/js/vendor/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<table class="table table-hover">
    <tr class="active">
        <th width="30">#id</th>
        <th>分类名称</th>
        <th width="210">操作</th>
    </tr>
    {volist name="cateDatas" id="cate"}
    <tr>
        <td>{$cate.cid}</td>
        <td>{$cate.cname}</td>
        <td>
            <a href="/admin/cate/{$cate.cid}/edit" class="btn btn-sm btn-warning">编辑</a>
            <a onclick="cateDel({$cate.cid})" class="btn btn-sm btn-danger">删除</a>

        </td>
    </tr>
    {/volist}
</table>

<script src="https://cdn.bootcss.com/jquery/2.1.0/jquery.min.js"></script>
<script>
    function cateDel(id) {
        if (!confirm('确认操作?')) {
            return;
        }
        $.ajax({
                type: "DELETE", //提交方式
                url: "/admin/cate/" + id,//路径
                dataType: 'Json',
                success: function (res) {
                    if (res.status == 1) {
                        alert('删除成功');
                        location.href = '/admin/cate';
                    } else {
                        var msg = res.msg;
                        alert(msg);
                    }
                }
            }
        )
    }
</script>

</body>
</html>
